import tkinter as tk
window = tk.Tk()
window.title('my window')
window.geometry('500x500')


var = tk.StringVar()
l = tk.Label(window, bg='yellow', width=20, text='empty')  # 字节数
l.pack()


def print_selection():
    l.config(text='you have selected '+var.get())


r1 = tk.Radiobutton(window, text='Option A', variable=var, value='A', command=print_selection)
r1.pack()
r2 = tk.Radiobutton(window, text='Option A', variable=var, value='B', command=print_selection)
r2.pack()
r3 = tk.Radiobutton(window, text='Option A', variable=var, value='C', command=print_selection)
r3.pack()  # 中间一段赋值用

window.mainloop()
